<template>
	<view class="p">
		<view class="grade_search">
			<view class="title">{{activeName}}</view>
			<view class="sear">
				<view class="sear_title">姓名</view>
				<view class="input">
					<view class="input_left"><i class="icon">&#xf12b;</i></view>
					<input type="text" v-model="info.name" placeholder-style="color:#e1e1e1;font-size:24upx" placeholder="请输入姓名" />
				</view>
			</view>
			<view class="sear">
				<view class="sear_title">参赛号</view>
				<view class="input">
					<view class="input_left"><i class="icon">&#xe669;</i></view>
					<input type="text" v-model="info.number" placeholder-style="color:#e1e1e1;font-size:28upx" placeholder="请输入参赛号" />
				</view>
			</view>
		</view>

		<!-- 查询 -->
		<view class="search" @tap="serachGrade">
			<i class="icon">&#xe63d;</i>
			查询
		</view>
		<view class="grade" v-if="gradeFlag" @tap="toresult">
			<view class="one">
				<view class="left">{{message.team_name}}</view>
				<view class="right">
					<i class="icon">&#xe60d;</i>
					查看证书
				</view>
			</view>
			<view class="two">
				<view class="two_top">
					<view class="two_top_item">姓名</view>
					<view class="two_top_item">参赛号</view>
					<view class="two_top_item">成绩</view>
				</view>
				<view class="two_bot">
					<view class="two_top_item">{{ grade_info[0].value }}</view>
					<view class="two_top_item">{{ grade_info[2].value }}</view>
					<view class="two_top_item two_top_item_g">{{ grade_info[5].value }}</view>
				</view>
			</view>
		</view>
		<!-- 没有成绩 -->
		<view class="nograde" v-if="noflag">
			<image src="https://ykp-new.oss-cn-hangzhou.aliyuncs.com/client/index/nodata.png" mode=""></image>
			<view class="nograde_info">暂无信息</view>
		</view>
		<navigation></navigation>
	</view>
</template>

<script>
import navigation from '@/components/navigation/navigation.vue';
export default {
	components: {
		navigation
	},
	data() {
		return {
			info: {},
			gradeFlag: false,
			active_id: '',
			grade_info: [],
			noflag: false,
			message: {},
			activeName: ''
		};
	},
	onLoad(options) {
		this.active_id = options.id;
		this.activeName = options.activeName
	},
	methods: {
		toresult() {
			this.message.active_name = this.activeName
			var content = JSON.stringify(this.message);
			uni.navigateTo({
				url: '/pageA/grade/certificate?content=' + content
			});
		},
		serachGrade() {
			if (!this.info.name) {
				this.toast('请输入参赛人姓名');
				return;
			}
			if (!this.info.number) {
				this.toast('请输入参赛号');
				return;
			}
			this.ajax('active/matchSearch', {
				data: {
					active_id: this.active_id,
					name: this.info.name,
					active_no: this.info.number
				},
				success: res => {
					 // console.log (res);
					if (!res.code) {
						this.toast(res.msg);
						this.noflag = true;
					} else {
						this.message = res.msg;
						this.grade_info = res.msg.form;
						this.noflag = false;
						this.gradeFlag = true;
					}
				}
			});
		}
	}
};
</script>

<style lang="less" scoped>
@import url('../../static/less/pageA/grade/grade.less');
</style>
